package com.sense.kukoo.biz_media.view

import android.os.Bundle
import android.text.TextUtils
import android.view.View
import com.sense.kukoo.biz_media.R
import com.sense.kukoo.biz_media.databinding.BizMediaFragmentSimpleDescriptionBinding
import com.sense.kukoo.biz_media.vm.SimpleDescriptionViewModel
import com.sense.kukoo.common.constant.ConstantConfig
import com.sense.kukoo.common.mvvm.view.BaseMvvmFragment

class SimpleDescriptionFragment: BaseMvvmFragment<SimpleDescriptionViewModel, BizMediaFragmentSimpleDescriptionBinding>() {

    private val TAG: String = javaClass.simpleName

    private var desText: String? = null

    override fun initParam() {}

    override fun responseVM(action: Int) {}

    override fun getLayout(): Int = R.layout.biz_media_fragment_simple_description

    override fun getViewModelClass(): Class<SimpleDescriptionViewModel> = SimpleDescriptionViewModel::class.java

    companion object {
        @JvmStatic
        fun newInstance() = SimpleDescriptionFragment()
    }

    override fun initData() {
        mBinding.lifecycleOwner = this
        mBinding.vm = mViewModel
    }

    override fun initView() {}

    fun setData(des: String){
        if (isViewModelInit()) {
            if (TextUtils.isEmpty(des)) {
                mBinding.tvDesFrom.visibility = View.GONE
                mBinding.tvHintText.visibility = View.VISIBLE
            } else {
                mBinding.tvDesFrom.text = des
                mBinding.tvDesFrom.visibility = View.VISIBLE
                mBinding.tvHintText.visibility = View.GONE
            }
        } else {
            desText = des
        }
    }

    override fun onResume() {
        super.onResume()
        desText?.let {
            setData(it)
        }
    }

}